<template>
  <div class="subject">
    <div v-for="(obj, index) in arr" :key="obj.id">
      <span>{{ obj.num1 }}</span>
      <span>+</span>
      <span>{{ obj.num2 }}</span>
      <span>=</span>
      <input v-model="obj.val" type="number" />
      <button @click="submitFn(index)">提交</button>
    </div>
  </div>
</template>

<script>
export default {
  props: ["arr"],
  methods: {
    submitFn(index) {
      // console.log(index);
      this.$emit("submitNum", index);
    },
  },
};
</script>

<style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>